package com.remenote.remenoteback.entity.vo;

import com.remenote.remenoteback.entity.doo.NoteDo;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;

import java.util.ArrayList;
import java.util.List;

/**
 * @BelongsProject: remenote-back
 * @BelongsPackage: com.remenote.remenoteback.entity.vo
 * @Author: 23392
 * @CreateTime: 2024-03-16  17:22
 * @Description: TODO
 * @Version: 1.0
 */
@Getter
@Setter
@Accessors(chain = true)
public class NoteVo {
    public String username;
    public String nickname;
    public Integer id;
    public String notebookName;
    public String title;
    public String content;
    public Boolean isPublic=false;

    public static NoteVo fromNoteDo(NoteDo note) {
        return new NoteVo().setTitle(note.getNoteTitle())
                .setId(note.getId())
                .setContent(note.getNoteContent())
                .setIsPublic(note.getIsPublic()).setNotebookName(note.getNotebook())
                .setUsername(note.getUsername());
    }
    public static NoteVo fromNoteDoWithNickname(NoteDo note,String nickname) {
        return new NoteVo().setTitle(note.getNoteTitle())
                .setId(note.getId())
                .setContent(note.getNoteContent())
                .setIsPublic(note.getIsPublic()).setNotebookName(note.getNotebook())
                .setUsername(note.getUsername())
                .setNickname(nickname);
    }

    public static List<NoteVo> fromNoteDoList(List<NoteDo> noteDoList) {
        List<NoteVo> noteVos = new ArrayList<>();
        for (NoteDo noteDo : noteDoList) {
            noteVos.add(NoteVo.fromNoteDo(noteDo));
        }
        return noteVos;
    }
    public static List<NoteVo> fromNoteDoListAndUserList(List<NoteDo> noteDoList) {
        List<NoteVo> noteVos = new ArrayList<>();
        for (NoteDo noteDo : noteDoList) {
            noteVos.add(NoteVo.fromNoteDo(noteDo));
        }
        return noteVos;
    }
}
